﻿using ApplicationBarMVVMApp.MVVM;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;

namespace ApplicationBarMVVMApp.ViewModels
{
    public class MainPageVM : INotifyPropertyChanged
    {
        #region Properties

        private string miTexto;

        public string MiTexto
        {
            get { return miTexto; }
            set { miTexto = value; RaisePropertyChanged(); }
        }

        #endregion Properties

        #region Command Properties

        private ICommand iconButtonCommand;

        public ICommand IconButtonCommand
        {
            get
            {
                if (null == iconButtonCommand)
                    iconButtonCommand = new RelayCommand(IconButtonExecute);
                return iconButtonCommand;
            }
        }

        private ICommand menuItemCommand;

        public ICommand MenuItemCommand
        {
            get
            {
                if (null == menuItemCommand)
                    menuItemCommand = new RelayCommand(MenuItemExecute);
                return menuItemCommand;
            }
        }

        #endregion Command Properties

        #region Command Methods

        private void MenuItemExecute()
        {
            this.MiTexto = "Acabas de presionar el MenuItem";
        }

        private void IconButtonExecute()
        {
            this.MiTexto = "Acabas de presionar el IconButton";
        }

        #endregion Command Methods

        #region INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged([CallerMemberName] string propertyName = null)
        {
            if (null != PropertyChanged)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion INotifyPropertyChanged
    }
}